package com.rmb.system.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.rmb.mart.entity.linxi.RmbSystemOperationLog;
import com.rmb.mart.entity.linxi.vo.RmbSystemOperationLogVo;
import com.rmb.system.dao.RmbSystemOperationLogDao;
import com.rmb.system.service.RmbSystemOperationLogService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (RmbSystemOperationLog)表服务实现类
 *
 * @author makejava
 * @since 2021-01-20 15:17:35
 */
@Service("rmbSystemOperationLogService")
public class RmbSystemOperationLogServiceImpl implements RmbSystemOperationLogService {
    @Resource
    private RmbSystemOperationLogDao rmbSystemOperationLogDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public RmbSystemOperationLog queryById(Long id) {
        return this.rmbSystemOperationLogDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<RmbSystemOperationLog> queryAllByLimit(int offset, int limit) {
        return this.rmbSystemOperationLogDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param rmbSystemOperationLog 实例对象
     * @return 实例对象
     */
    @Override
    public RmbSystemOperationLog insert(RmbSystemOperationLog rmbSystemOperationLog) {
        this.rmbSystemOperationLogDao.insert(rmbSystemOperationLog);
        return rmbSystemOperationLog;
    }

    /**
     * 修改数据
     *
     * @param rmbSystemOperationLog 实例对象
     * @return 实例对象
     */
    @Override
    public RmbSystemOperationLog update(RmbSystemOperationLog rmbSystemOperationLog) {
        this.rmbSystemOperationLogDao.update(rmbSystemOperationLog);
        return this.queryById(rmbSystemOperationLog.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.rmbSystemOperationLogDao.deleteById(id) > 0;
    }

    /**
     * 查新操作列表
     * @param rmbSystemOperationLogVo 分页数据
     * @return 列表
     */
    @Override
    public PageInfo<RmbSystemOperationLog> findList(RmbSystemOperationLogVo rmbSystemOperationLogVo) {
        PageHelper.startPage(rmbSystemOperationLogVo.getPage(),rmbSystemOperationLogVo.getSize());
        return new PageInfo<>(rmbSystemOperationLogDao.findList(rmbSystemOperationLogVo));
    }
}